﻿@model FCNS.ERP.Models.ErpProductMultipleUnit

@{
    ViewBag.Title = "一品多码-新增";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>@ViewBag.Title</h2>

<script type="text/javascript">
    $(document).ready(function () { 
        $(".newObjAnoText").click(function () {
            var a = prompt();
            if (a == null || a == '')
                return;

            var dataType = $(this);
            $.post("/Basic/UnitNewAdd",
                {
                    name: a,
                    flag: $(this).attr("data-Type")
                }
                ,
                function (data, status) {
                    if (status == "success") {
                        if (data == "-1") {
                            alert("数据添加异常");
                        }
                        else {
                                $("#UnitId").append("<option value='" + data + "'>" + a + "</option>");
                                $("#UnitId").val(data);
                        }
                    }
                    else {
                        alert("操作失败");
                    }
                });
            return true;
        });
    });
</script>

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <input type="hidden" value="@ViewData["ProductId"]" />

        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
            @Html.LabelFor(model => model.Enable, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                <div class="checkbox">
                    @Html.CheckBoxFor(model => model.Enable, htmlAttributes: new { @checked = "checked" })
                    @Html.ValidationMessageFor(model => model.Enable, "", new { @class = "text-danger" })
                </div>
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.ProductId, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                <input class="form-control text-box single-line"   type="text" value="@ViewData["ProductName"]" />
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Barcode, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Barcode, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Barcode, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.UnitId, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                <table class="table-condensed">
                    <thead>
                        <tr>
                            <th>
                                @Html.DropDownList("UnitId", ViewData["Unit"] as SelectList, htmlAttributes: new { @class = "form-control", @style = "width:300px;" })
                            </th>
                            <th>
                                <a class="newObjAnoText" href="#" data-Type="0"></a>
                            </th>
                        </tr>
                    </thead>
                </table> 
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Count, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Count, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Count, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="保存" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    <a class="backToListImg" href="/Basic/ProductMultipleUnit">返回</a>
</div>
